﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ChurchData.Business;

namespace ChurchData
{
    public partial class ChangePasswordForm : ChurchForm
    {
        public ChangePasswordForm()
        {
            InitializeComponent();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidEntries()) this.SavePassword();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private bool ValidEntries()
        {
            if (this.txtPassword.Text.Trim() == this.txtRetype.Text.Trim())
                return true;
            else
            {
                MessageBox.Show("Entries do not match");
                return false;
            }
        }

        private void SavePassword()
        {
            EmployeeBO eBO = new EmployeeBO();
            eBO.ChangePassword(UserInformation.EmployeePK, txtPassword.Text.Trim());
            MessageBox.Show("Your password has been updated");
            this.Close();
        }
    }
}